/* 全局样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: #f5f7fa;
  color: #333;
  min-height: 100vh;
  overflow: hidden;
}

/* 主容器布局 */
.manager-container {
  display: flex;
  height: 100vh;
}

/* 左侧边栏样式 */
.sidebar {
  width: 280px;
  background: white;
  border-right: 1px solid #e1e8ed;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #e1e8ed;
}

.tag-item {
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.tag-item:hover {
  background-color: #e9ecef;
}

.tag-item.active {
  background-color: #007bff;
  color: white;
}

.tag-count {
  background-color: rgba(0,0,0,0.1);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.tag-item.active .tag-count {
  background-color: rgba(255,255,255,0.2);
}

.sidebar-header h1 {
  font-size: 24px;
  font-weight: 600;
  color: #333;
  margin-bottom: 16px;
}

#add-tag-btn {
  width: 100%;
  padding: 10px 16px;
  background: #f0f2f5;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #666;
}

#add-tag-btn:hover {
  background: #e1e5e9;
  color: #333;
}

.tags-section {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}

.tags-section h2 {
  font-size: 16px;
  font-weight: 500;
  color: #666;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tag-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tag-item {
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
}

.tag-item:hover {
  background: #e9ecef;
}

.tag-item.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.tag-count {
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}

.tag-item:not(.active) .tag-count {
  background: #e1e5e9;
  color: #666;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid #e1e8ed;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#export-btn, #import-btn {
  width: 100%;
  padding: 10px 16px;
  background: #f0f2f5;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #666;
}

#export-btn:hover, #import-btn:hover {
  background: #e1e5e9;
  color: #333;
}

/* 右侧内容区域样式 */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-bar {
  padding: 20px;
  background: white;
  border-bottom: 1px solid #e1e8ed;
}

.top-bar h2 {
  font-size: 24px;
  font-weight: 600;
  color: #333;
  margin-bottom: 16px;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.form-group {
  flex: 1;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e1e5e9;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.3s ease;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#add-button {
  padding: 12px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

#add-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.current-selection {
  padding: 16px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #e1e8ed;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#current-tag-name {
  font-size: 18px;
  font-weight: 500;
  color: #333;
}

.search-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

#search-input {
  padding: 8px 12px;
  border: 2px solid #e1e5e9;
  border-radius: 6px;
  font-size: 14px;
  width: 200px;
  transition: border-color 0.3s ease;
}

/* 批量操作栏样式 */
.batch-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
}

#selected-count {
  font-weight: 500;
  color: #495057;
}

#batch-delete-btn {
  background-color: #dc3545;
  color: white;
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  margin-left: 12px;
  transition: background-color 0.2s ease;
}

#batch-delete-btn:hover {
  background-color: #c82333;
}

#cancel-selection-btn {
  background-color: #6c757d;
  color: white;
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  margin-left: 8px;
  transition: background-color 0.2s ease;
}

#cancel-selection-btn:hover {
  background-color: #5a6268;
}

#search-input:focus {
  outline: none;
  border-color: #667eea;
}

#search-button {
  padding: 8px 16px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

#search-button:hover {
  background: #5a67d8;
}

.bookmarks-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.bookmarks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.bookmarks-header span {
  font-size: 16px;
  font-weight: 500;
  color: #666;
}

.sort-options {
  display: flex;
  align-items: center;
  gap: 8px;
}

#sort-select {
  padding: 6px 12px;
  border: 2px solid #e1e8ed;
  border-radius: 6px;
  font-size: 14px;
  background: white;
  cursor: pointer;
  transition: border-color 0.3s ease;
}

#sort-select:focus {
  outline: none;
  border-color: #667eea;
}

.bookmarks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 16px;
}

.bookmark-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
}

.bookmark-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
  border-color: #e1e8ed;
}

.bookmark-card.selected {
  border: 2px solid #007bff;
  background-color: #f0f7ff;
}

.bookmark-card.selected::before {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  background-color: #007bff;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

.bookmark-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  border-color: #e1e8ed;
}

.bookmark-card h3 {
  font-size: 18px;
  font-weight: 500;
  color: #333;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookmark-url {
  color: #667eea;
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 12px;
  display: block;
  word-break: break-all;
}

.bookmark-url:hover {
  text-decoration: underline;
}

.bookmark-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.bookmark-card-tag {
  background: #f0f2f5;
  color: #666;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.bookmark-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.bookmark-edit-btn, .bookmark-delete-btn {
  padding: 6px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin: 0 4px;
}

.bookmark-card-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.bookmark-edit-btn {
  background: #4ecdc4;
  color: white;
}

.bookmark-edit-btn:hover {
  background: #45b7aa;
}

.bookmark-delete-btn {
  background: #ff6b6b;
  color: white;
}

.bookmark-delete-btn:hover {
  background: #ff5252;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.empty-state p {
  font-size: 16px;
  margin-bottom: 8px;
}

.empty-state small {
  font-size: 14px;
}

/* 模态框样式 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid #e1e8ed;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 600;
  color: #333;
}

.close-btn {
  font-size: 24px;
  cursor: pointer;
  color: #999;
  transition: color 0.3s ease;
}

.close-btn:hover {
  color: #333;
}

.modal-body {
  padding: 20px;
}

.modal-body .form-group {
  margin-bottom: 16px;
}

.modal-body label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  color: #666;
}

.modal-footer {
  padding: 20px;
  border-top: 1px solid #e1e8ed;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

#save-edit-btn {
  padding: 10px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

#save-edit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

#cancel-edit-btn {
  padding: 10px 24px;
  background: #f0f2f5;
  color: #666;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

#cancel-edit-btn:hover {
  background: #e1e5e9;
  color: #333;
}

/* 滚动条样式 */
.sidebar::-webkit-scrollbar,
.bookmarks-area::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.bookmarks-area::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb,
.bookmarks-area::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.bookmarks-area::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .sidebar {
    width: 240px;
  }
  
  .form-row {
    flex-wrap: wrap;
  }
  
  .bookmarks-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

@media (max-width: 768px) {
  .manager-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: 200px;
  }
  
  .tags-section {
    overflow-y: auto;
  }
  
  .tag-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .tag-item {
    flex: 1;
    min-width: 100px;
  }
  
  .form-row {
    flex-direction: column;
  }
  
  .current-selection {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  
  .search-bar {
    justify-content: center;
  }
}